#!/bin/bash

grep_httperf()
{
	app=$1
	page=$2
	nconn=$3
	rate=$4
	result_file=$5
	echo "$app $page $nconn $rate"
	filename=httperf_data/baseline_${app}_${page}_page_n${nconn}_r${rate}.txt
	echo -n "$rate " >> $result_file
	if [ -e $filename ] ; then
		grep "Reply time" $filename | cut -d" " -f5,7 >> $result_file
	fi
}

for app in apache django
do
	for page in static app app_data
	do
		result_file="results/reply_time_${app}_${page}.csv"
		echo "load response transfer" > $result_file
		grep_httperf $app $page 50 1 $result_file
		grep_httperf $app $page 50 1 $result_file
		grep_httperf $app $page 1000 10 $result_file
		grep_httperf $app $page 1000 25 $result_file
		grep_httperf $app $page 1500 50 $result_file
		grep_httperf $app $page 5000 100 $result_file
	done
done

